package com.jwell.bigdata.base

import android.os.Bundle


/**
 * MVP模式下的基础Fragment
 */
abstract class MVPBaseFragment<P : BasePresenter<*>> : BaseFragment() {

    public var presenter: P? = null
    var init = false
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        presenter = createPresenter()
        presenter?.attachView(this)
    }

    abstract fun createPresenter(): P?
    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        presenter?.start()
    }

    override fun onDestroy() {
        presenter?.unSubscrib()
        presenter?.deattachView()
        presenter = null
        super.onDestroy()
    }
}
